#ifndef THREAD_H
#define THREAD_H

#include"Public.h"

/*
 * The Headerfile Extends by GThreadPool
 * which is recommanded by Glib
 */

#define MaxDownLoadThread 10
#define MaxUploadThread 10

typedef struct _GThreadPool D_ThreadPool;
typedef struct _GThread D_ThreadObj;

D_ThreadPool *CreateNewThreadPool(GFunc func,
                                 gpointer UserData,gint max_threads, GError **error);

D_ThreadObj *NewThreadCreate(const gchar *name,GThreadFunc func,gpointer data);

#define ThreadJoin(thread) \
    (g_thread_join((thread)))

#define DestroyThreadPool(thread_pool) \
    (g_thread_pool_free((thread_pool),(FALSE),(TRUE)))

#define DownloadFilePool(func, UserData,error) \
    (CreateNewThreadPool((func),(UserData),(MaxDownLoadThread),(error)))

#define UploadFilePool(func, UserData,error) \
    (CreateNewThreadPool((func),(UserData),(MaxUploadThread),(error)))

#define ThreadPoolPush(threadpool,data,error) \
    (g_thread_pool_push((threadpool),(data),(error)))

#endif // THREAD_H
